Ranking and unranking permutations in linear time

نویسندگان

  • Wendy J. Myrvold
  • Frank Ruskey
چکیده

A ranking function for the permutations on n symbols assigns a unique integer in the range [0, n! − 1] to each of the n! permutations. The corresponding unranking function is the inverse: given an integer between 0 and n! − 1, the value of the function is the permutation having this rank. We present simple ranking and unranking algorithms for permutations that can be computed using O(n) arithmetic operations.  2001 Elsevier Science B.V. All rights reserved.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Ranking and Unranking of Hereditarily Finite Functions and Permutations

Prolog’s ability to return multiple answers on backtracking provides an elegant mechanism to derive reversible encodings of combinatorial objects as Natural Numbers i.e. ranking and unranking functions. Starting from a generalization of Ackerman’s encoding of Hereditarily Finite Sets with Urelements and a novel tupling/untupling operation, we derive encodings for Finite Functions and use them a...

متن کامل

Ranking Catamorphisms and Unranking Anamorphisms on Hereditarily Finite Datatypes

Using specializations of unfold and fold on a generic tree data type we derive unranking and ranking functions providing natural number encodings for various Hereditarily Finite datatypes. In this context, we interpret unranking operations as instances of a generic anamorphism and ranking operations as instances of the corresponding catamorphism. Starting with Ackerman’s Encoding from Hereditar...

متن کامل

Ranking and Unranking Left Szilard Languages

We give efficient ranking and unranking algorithms for left Szilard languages of context-free grammars. If O(n2) time and space preprocessing is allowed then each ranking operation is possible in linear time. Unranking takes time O(n log n). These algorithms imply similar algorithms for context-free languages generated by arbitrary unambiguous context-free grammars.

متن کامل

A New Method for Generating Permutations in Lexicographic Order

First, an ordinal representation scheme for permutations is defined. Next, an “unranking” algorithm that can generate a permutation of n items according to its ordinal representation is designed. By using this algorithm, all permutations can be systematically generated in lexicographic order. Finally, a “ranking” algorithm that can convert a permutation to its ordinal representation is designed...

متن کامل

Ranking and Unranking of Lexicographically Ordered Words: An Average-Case Analysis

We consider all words of length n of a formal language. If these words are arranged according to the lexicographical order, then ranking means to determine the position of a word of the language. Unranking is the inverse operation of ranking. For a given formal language we compute the average length of the minimal preex of a word to be read to determine its position, if the word is read from le...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:
  • Inf. Process. Lett.

دوره 79  شماره 

صفحات  -

تاریخ انتشار 2001